// printRoom Mannamge
Array.prototype.unique = function() {
	var a = [],k = 0,e;
	for(k=0;e=this[k];k++)
		if(a.indexOf(e)==-1)
			a.push(e);
	return a;
}
function printRoomManagementSinggle(data){
	objArray = data;
	var groupIdDisplay = "";
	var RoomNight = "";
	var Night = 0;
	var roomType = "";
	var adult = 0;
	var packetPrice = "";
	var defalutCharge = 0;
	var tax = 0;
	var priceSumTax = 0;
	var paymentAmount = 0;
	var balance = 0;
	var reservationOrGroup = "";
	if(objArray.groupId!="0"){
		var roomTypeArray = new Array();
		var packetPriceArray = new Array();
		groupIdDisplay  = "Group ID # G"+objArray.groupId;
		if(objArray.subList!=undefined){
			for(var i =0;i<objArray.subList.length;i++){
				roomTypeArray.push(objArray.subList[i].roomTypeName);
				packetPriceArray.push(objArray.subList[i].pracketPrice);
				RoomNight += '<font size="-1">'+objArray.subList[i].roomName+'</font><font size="-2">('+objArray.subList[i].span+'N)</font>,';
				Night = parseInt(objArray.subList[i].span)+Night;
				adult = parseInt(objArray.subList[i].adult)+parseInt(objArray.subList[i].child)+adult;
				defalutCharge = parseInt(objArray.subList[i].defaultCherge)+defalutCharge;
				tax = parseInt(objArray.subList[i].tax)+tax;
				priceSumTax = parseInt(objArray.subList[i].totaltax)+priceSumTax;
				paymentAmount = parseInt(objArray.subList[i].paymentAmount)+paymentAmount;
				balance = parseInt(objArray.subList[i].balance)+balance;
			}
			RoomNight = RoomNight.substring(0, RoomNight.length-1);
			roomType = roomTypeArray.unique().toString();
			packetPrice = packetPriceArray.unique().toString();
			reservationOrGroup = '<td><h4> '+groupIdDisplay+'</h4></td></tr></tbody>';
		}else{
			RoomNight = '<font size="-1">'+objArray.roomName+'</font><font size="-2">('+objArray.span+'N)</font>';
			roomType = objArray.roomTypeName;
			Night = objArray.span;
			adult = parseInt(objArray.adult)+parseInt(objArray.child);
			packetPrice = objArray.pracketPrice;
			defalutCharge = objArray.defaultCherge;
			tax = objArray.tax;
			priceSumTax = objArray.totaltax;
			paymentAmount = objArray.paymentAmount;
			balance = objArray.balance;
			reservationOrGroup = '<td><h4> '+groupIdDisplay+'&nbsp;&nbsp;&nbsp;Reservation ID # '+objArray.id+'</h4></td></tr></tbody>';
		}
	}else{
		RoomNight = '<font size="-1">'+objArray.roomName+'</font><font size="-2">('+objArray.span+'N)</font>';
		roomType = objArray.roomTypeName;
		Night = objArray.span;
		adult = parseInt(objArray.adult)+parseInt(objArray.child);
		packetPrice = objArray.pracketPrice;
		defalutCharge = objArray.defaultCherge;
		tax = objArray.tax;
		priceSumTax = objArray.totaltax;
		paymentAmount = objArray.paymentAmount;
		balance = objArray.balance;
		reservationOrGroup = '<td><h4>Reservation ID # '+objArray.id+'</h4></td></tr></tbody>';
	}
	myWindow=window.open('','','width=783,height=722');
var headHtml = '<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">' +
	'<title>Room Reservation Check In</title>' +
	'<script src="js/jquery-1.8.3.min.js"></script>'+
	'<link href="https://695.staygrid.com/styles/billmsg.css" rel="stylesheet" type="text/css">' +
	'<style media="print">' +
	'.dont-print-buttom{' +
	'display:none;' +
	'}' +
	'P.pagebreakhere {page-break-before: always}' +
	'</style>'+
	'<script>'+
	"var display = 0;"+
	'function showPrice(){'+
		'if(display == 0){'+
			'$("#displayPrice").attr("style","display:none"); $("#displayPrice2").attr("style","display:show"); display=1;'+
		'}else{'+
			'$("#displayPrice").attr("style","display:show"); $("#displayPrice2").attr("style","display:none"); display=0;'+
		'}'+
	'}'+
	'</script>'+
	'</head><body>';
var hotel = '<table align="center" bgcolor="#FFFFFF" border="0" cellpadding="10" cellspacing="0" width="100%">' +
	'<tbody>' +
	'<tr>' +
	'<td width="65%">' +
	'<img src="https://s3.amazonaws.com/livestaygriddata/product-images/hotels/logo/logo08042013072057140130407.jpeg" width="152.36276849642" height="160">' +
	'</td>' +
	'<td width="35%">' +
	'<table width="100%">' +
	'<tbody>' +
	'<tr>' +
	'<td>' +
	'<table style="font-size:11px" width="100%" border="0" cellpadding="0" cellspacing="0"><tbody><tr><td colspan="2" style="font-size:14px"><strong>iHotel</strong></td></tr><tr><td colspan="2" width="100%" valign="top">......................................<br>Thakor - 48000<br>Nakhon Phanom, Thailand</td></tr><tr><td width="10%"><strong>Phone:</strong></td><td width="90%">+6642543355</td></tr><tr><td><strong>Fax:</strong></td><td>+6642543377</td></tr><tr><td><strong>Email:</strong></td><td>ihotelthailands@gmail.com</td></tr><tr><td><strong>Website:&nbsp;</strong></td><td>www.ihotel.co.th</td></tr></tbody></table>' +
	'</td>' +
	'</tr>' +
	'</tbody>' +
	'</table>' +
	'</td>' +
	'</tr>' +
	'</tbody>' +
	'</table>';
var Comfort = '<table style="font-size:11px" border="0" align="center" cellpadding="10" cellspacing="0" bgcolor="#FFFFFF" class="border" width="100%">' +
	'<tbody><tr>' +
	'<td  width="100%" colspan="2">Make Your Comfort</td></tr></tbody></table>';
var reservationId = '<table align="center" border="0" cellpadding="15" cellspacing="0" width="100%">' +
	'<tbody><tr><td><h4>Check-in Card</h4></td><td></td>' +
	reservationOrGroup +
	'</table>';
var roomType = '<table align="center" bgcolor="#FFFFFF" border="0" cellpadding="15" cellspacing="0" class="border" width="100%">' +
	'<tbody>' +
	'<tr>' +
	'<td width="50%">' +
	'<h1>Room Type: ' +
		roomType +
	'</h1>' +
	'</td>' +
	'<td align="right" width="50%">' +
	'<h1>Room : '+RoomNight+'</h1>' +
	'</td>' +
	'</tr>' +
	'</tbody>' +
	'</table>';
	var dateIn = new Date(objArray.date);
	var dateTo = new Date(objArray.dateTo);
	var dateToYear = dateTo.getFullYear();
	var dateToMonth = dateTo.getMonth();
	var dateToDay = dateTo.getDate();
	var dateInYear = dateIn.getFullYear();
	var dateInMonth = dateIn.getMonth();
	var dateInDay = dateIn.getDate();
	var DateFormatTo = dateToYear+'-'+dateToMonth+'-'+dateToDay;
	var DateFormatIn = dateInYear+'-'+dateInMonth+'-'+dateInDay;
	var formatDateIn = checkin_checkoutdatepicker(DateFormatIn);
	var formatDateTo = checkin_checkoutdatepicker(DateFormatTo);
	var gusetId = "";
	var name = "";
	var phone = "";
	if(objArray.guestId!=0){gusetId = objArray.guestId;}
	if(objArray.name!=undefined){name = objArray.name;}
	if(objArray.phone!=undefined){phone = objArray.phone;}
	var hidePrice = '<tbody><tr><td align="center" nowrap="nowrap" width="100%"><h1>Guest Booking Price</h1></td></tr></tbody>';
	var dataResevation = '<table align="center" border="0" cellpadding="3" cellspacing="0" class="border" width="100%">' +
	'<tbody><tr><td valign="top" width="50%">'+
	'<table width="100%" border="0" cellspacing="0" cellpadding="3"><tbody><tr>'+
	'<td width="23%" nowrap="nowrap" class="check-card"><em>Guest Id: </em></td>'+
	'<td width="77%" class="check-card"><strong>P'+gusetId+'</strong></td></tr><tr>'+
	'<td width="23%" nowrap="nowrap" class="check-card"><em>Name: </em></td>'+
	'<td width="77%" class="check-card"><strong>'+name+'&nbsp;.</strong></td></tr><tr><td colspan="2">&nbsp;</td></tr><tr>' +
	'<td class="check-card"><em>Phone:</em></td>' +
	'<td class="check-card"><strong>.</strong></td>' +
	'</tr><tr>' +
	'<td class="check-card"><em>Mobile:</em></td>' +
	'<td class="check-card"><strong>'+phone+'</strong></td>' +
	'</tr><tr><td colspan="2" class="check-card">&nbsp;</td></tr></tbody></table></td>' +
	'<td nowrap="nowrap" valign="top" width="50%"><table border="0" cellpadding="3" cellspacing="0" width="100%">' +
	'<tbody><tr><td class="check-card" width="31%"> <em>Date(s): </em></td><td class="check-card" width="69%">'+
	'<strong>'+formatDateIn+' - '+formatDateTo+'</strong>' +
	'</td></tr><tr><td class="check-card"><em>Night(s): </em></td>' +
	'<td class="check-card"><strong>'+Night+'</strong></td></tr>' +
	'<tr><td class="check-card"><em>Person(s):</em></td>' +
	'<td class="check-card"><strong>'+adult+' Adults</strong></td>' +
	'</tr><tr><td colspan="2">&nbsp;</td></tr><tr><td colspan="2" valign="bottom">' +
	'<table id="displayPrice2" style="display:none;" border="0" cellpadding="1" cellspacing="0" class="border" height="120" width="100%">' +
	hidePrice+
	'</table>'+
	'<table id="displayPrice" style="display:show;" border="0" cellpadding="1" cellspacing="0" class="border" height="120" width="100%">' +
	'<tbody > <tr><td align="left" class="check-card" nowrap="nowrap" style="font-size:12px;" width="50%">' +
	'<em>Booking Charges</em><br><em>('+packetPrice+')</em></td>' +
	'<td align="right" class="check-card" style="font-size:12px;" width="50%">' +
	'&nbsp;'+toCurrencyString(parseInt(defalutCharge))+
	'</td></tr><tr>' +
	'<td align="left" class="check-card" nowrap="nowrap" style="font-size:12px;">' +
	'<em>Total Tax</em>' +
	'</td>' +
	'<td align="right" class="check-card" style="font-size:12px;">' +
	'&nbsp;'+toCurrencyString(parseInt(tax))+
	'</td></tr><tr>' +
	'<td align="left" class="check-card" nowrap="nowrap" style="font-size:12px;">' +
	'<strong><em>Total Amount</em></strong>' +
	'</td><td align="right" class="check-card" style="font-size:12px;">' +
	'<strong>&nbsp;'+toCurrencyString(parseInt(priceSumTax))+'</strong>' +
	'</td></tr><tr><td align="left" class="check-card" nowrap="nowrap" style="font-size:12px;">' +
	'<strong><em>Amount Paid</em></strong>' +
	'</td><td align="right" class="check-card" style="font-size:12px;">' +
	'<strong>&nbsp;'+toCurrencyString(parseInt(paymentAmount))+'</strong></td></tr>' +
	'<tr><td align="left" class="check-card" nowrap="nowrap" style="font-size:12px;">' +
	'<strong><em>Balance</em></strong></td>' +
	'<td align="right" class="check-card" style="font-size:12px;"><strong>&nbsp;'+toCurrencyString(parseInt(balance))+'</strong>' +
	'</td></tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table>';
	var messageBot = '<table style="font-size:11px" border="0" align="center" cellpadding="10" cellspacing="0" bgcolor="#FFFFFF" class="border" width="100%">'+
	'<tbody><tr>'+	
	'<td width="100%" colspan="2">Thank you so much</td></tr></tbody></table>';
	var dateNow = new Date();
	var dateNowYear = dateNow.getFullYear();
	var dateNowMonth = dateNow.getMonth();
	var dateNowDay = dateNow.getDate();
	var DateFormatNow = dateNowYear+'-'+dateNowMonth+'-'+dateNowDay;
	var formatDateNow = checkin_checkoutdatepicker(DateFormatNow);
	var dateDisplay = '<table style="font-size:11px" align="center" border="0" cellpadding="5" cellspacing="0" width="100%">'+
		'<tbody>'+
		'<tr><td colspan="4">&nbsp;</td></tr>'+
		' <tr><td align="left" nowrap="nowrap" width="7%"><strong>Date:</strong></td>'+
		'<td align="left" nowrap="nowrap" width="17%"> '+formatDateNow+' </td>'+
		'<td align="right" width="60%"><strong>Signature:</strong></td>'+
		'<td align="left" rowspan="2" valign="top" width="16%">&nbsp;</td>'+
		'</tr></tbody></table>';
	var btnbot = '<form action="https://695.staygrid.com/admine/billmessage/preview/billType/I/id/2617/groupId/147993/rsvId/0/fromTape/1" method="post" name="shFrm">'+
		 '<input type="hidden" name="hidePriceReq" value="1">'+
		 '<table align="center" width="100%">'+
		 '<tbody><tr>'+
		 '<td align="center">'+
		 '<input name="btnClose" type="button" onclick="window.close();" value="Close" class="dont-print-buttom">'+
		 '<input name="btnPrint" type="button" onclick="window.print();" value="Print" class="dont-print-buttom">'+
		 '<input name="btnShowHide" type="button" onclick="showPrice();" value="Hide Price" class="dont-print-buttom"></td></tr></tbody></table></form> ';
	
	myWindow.document.write(headHtml+hotel+Comfort+reservationId+roomType+dataResevation+messageBot+dateDisplay+btnbot+'</body></html>');
	myWindow.focus();
}